package com.cabd.service.impl;

import com.cabd.staticfinal.DownLoadAndUpLoadPath;
import com.cabd.utils.CSVUtils;

public class PredictPage {
	private int times = 0;
	private String fileName = null;
	private String folderName = null;
	private int onePageNumbers = 0;
	private int begin = 0;
	private int end = 0;
	public int getTimes() {
		return times;
	}
	public void setTimes(int times) {
		this.times = times;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public String getFolderName() {
		return folderName;
	}
	public void setFolderName(String folderName) {
		this.folderName = folderName;
	}
	public int getOnePageNumbers() {
		return onePageNumbers;
	}
	public void setOnePageNumbers(int onePageNumbers) {
		this.onePageNumbers = onePageNumbers;
	}
	public int getBegin() {
		begin = 0 + times*onePageNumbers;
		return begin>=0?begin:0;
	}
	public void setBegin(int begin) {
		this.begin = begin;
	}
	public int getEnd() {
		String path = DownLoadAndUpLoadPath.downLoadAndUpLoadPath+"\\"+folderName+"\\output\\"+fileName;
		int recordNumber = CSVUtils.getRecordNumber(path);
		end = (times+1)*onePageNumbers;
		return end<=recordNumber?end:recordNumber;
	}
	public void setEnd(int end) {
		this.end = end;
	}
	public void next() {
		times++;		
	}
	public void prior() {
		times--;
	}
	public void first() {
		System.out.println("into first");
		this.setBegin(0);
		this.setEnd(500);
		this.setTimes(0);
	}
	public int pagesNumber() {
		String path = DownLoadAndUpLoadPath.downLoadAndUpLoadPath+"\\"+folderName+"\\output\\"+fileName;
		int recordNumber = CSVUtils.getRecordNumber(path);
		return recordNumber/onePageNumbers+1;
	}
}
